-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Added perf_event_header definition #24264
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
I've also noticed that perf_event_mmap_page is missing. Here's a possible translation: pub const perf_event_mmap_page = extern struct {
version: u32,
compt_version: u32,
lock: u32,
index: u32,
offset: i64,
time_enabled: u64,
time_running: u64,
capabilities: extern union {
capabilities: u64,
cap: packed struct {
bit0: u1,
bit0_is_deprecated: u1,
user_rdpmc: u1,
user_time: u1,
user_time_zero: u1,
user_time_short: u1,
____res: u58,
},
},
pcm_width: u16,
time_shift: u16,
time_mult: u32,
time_offset: u64,
time_zero: u64,
size: u32,
__reserved_1: u32,
time_cycles: u64,
time_mask: u64,
__reserved: [116 * 8]u8,
data_head: u64,
data_tail: u64,
data_offset: u64,
data_size: u64,
aux_head: u64,
aux_tail: u64,
aux_offset: u64,
aux_size: u64,
}; I'm not including it yet in this PR because the capabilities field adds a small naming/layout decision — the Zig version would need to be accessed like: _ = m.capabilities.capabilities;
// or
_ = m.capabilities.cap.bit0; while in c would be m.capabilities;
// or
m.cap_bit0; Since this is my first PR to Zig, I’d rather not make that call on my own. If there’s a preferred naming or layout approach here, I’d be glad to follow up with a separate PR or add it to this one as a second commit. |
I think |
I added the I also noticed that the current |
Sure, might as well include that if you feel like it. |
While using the Linux perf subsystem in sampling mode, I noticed that the perf_event_header struct and its associated constants were missing from the bindings. This struct is essential as a building block for user-defined structs that can be bitcast to the events in the mmaped output region.
The struct definition and constants are based on the uapi source.
I tried to keep the style and naming consistent with the rest of the codebase. Since this is my first PR to the project, please let me know if anything needs adjustment.